function Outliner(){
	this.outliner = document.getElementById('outliner');
	this.init();
	this.number;
}

Outliner.prototype.addOutlinerItem = function (name,id){
	var scope = this;
	var item = document.createElement('div');
	item.innerHTML = name;
	// item.style.background = "#3399ff";
	item.style.cursor = "pointer";
	item.id= id;

	
	this.outliner.appendChild(item);
	this.number = this.outliner.childNodes.length;
	if(this.number >2){
		for(var i = 1;i < this.number - 1;i++){
			this.outliner.childNodes[i].className = "none";
		}
		this.outliner.childNodes[i].className = "selected";
	}
	
	// console.log("this.number");
	// console.log(this.number);
	// console.log(this.outliner.childNodes);

	// this.outliner.appendChild(document.createElement('br'));
	//通过物体的item的id 也就是传入的id拾取物体
	item.addEventListener("click", function(){
		var relevantObject = scene.getObjectById(parseInt(this.id));
		if(relevantObject == null || relevantObject == undefined){
			return;
		}
		if(relevantObject.type == "Mesh" || relevantObject.type == "PointLight" || relevantObject.type == 'AmbientLight'){
			activeObject = relevantObject;
		}
		else if(relevantObject.type == "SpotLight" || relevantObject.type == "DirectionalLight"){	
			activeObject = relevantObject.helper;
		}	
		control.attach(relevantObject);
		propertyPanel.update();
		if(scope.number >2){
		for(var i = 1;i < scope.number;i++){
			scope.outliner.childNodes[i].className = "none";
		}
		this.className = "selected";
	}
	
	});
}

Outliner.prototype.removeOutlinerItem = function(id){
	var item = document.getElementById(id);
	// console.log(item);
	// console.log(this.outliner);
	// console.log(this.outliner.childNodes);
	// console.log("item.parentNode");
	// console.log(item.parentNode);
	// item.parentNode.removeChild(item);
	this.outliner.removeChild(item);
	this.number = this.outliner.childNodes.length;
}

Outliner.prototype.init = function(){
	this.addOutlinerItem('scene');
}

Outliner.prototype.updateName = function(name,id){
	document.getElementById(id).innerHTML = name;

	// console.log('changed!!!!!!!!!!!!!!!!!!!!!!!!!1');
}

Outliner.prototype.update = function(id){
	var item = document.getElementById(id);
	if(this.number >2){
		for(var i = 1;i < this.number;i++){
			this.outliner.childNodes[i].className = "none";
		}
		item.className = "selected";
	}
}


